{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9854cac8-ff6a-4d42-a93c-36259d905204",
   "metadata": {},
   "source": [
    "### 1,最大最小值归一化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "90358c09-d28b-4f65-82db-8242958e4f08",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import MinMaxScaler\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "498d5ee1-9ace-42ed-aa88-d381c450204a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.  ],\n",
       "       [0.25],\n",
       "       [0.5 ],\n",
       "       [1.  ],\n",
       "       [1.  ]])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scaler = MinMaxScaler()\n",
    "temp = np.array([1,2,3,5,5])\n",
    "scaler.fit_transform(temp.reshape(-1,1))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd6c094b-7556-41b4-87d6-fccf98a2fea1",
   "metadata": {},
   "source": [
    "### 2，标准归一化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a2808499-40f9-4e2f-93bf-d92245017325",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import StandardScaler"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "342bcade-a36b-49a1-a1f2-6cfed215f3b3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-1.375],\n",
       "       [-0.75 ],\n",
       "       [-0.125],\n",
       "       [ 1.125],\n",
       "       [ 1.125]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scaler = StandardScaler()\n",
    "temp = np.array([1,2,3,5,5])\n",
    "scaler.fit_transform(temp.reshape(-1,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e4d3841a-03d8-4e8c-9c9e-0e7e2f0943aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.5000875 ],\n",
       "       [-0.5000375 ],\n",
       "       [-0.4999875 ],\n",
       "       [-0.49988749],\n",
       "       [ 2.        ]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "temp1 = np.array([1, 2, 3, 5, 50001])\n",
    "scaler.fit_transform(temp1.reshape(-1,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bc23ed04-c3b5-4ddf-864e-93a91c4c1119",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
